/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://github.com/mineadmin
 */

import type { MaSearchItem } from "@mineadmin/search";
import MaRemoteSelect from "@/components/ma-remote-select/index.vue";
import { page as commodityTypePage } from "$/attractions/commerce/api/commerceCommodityType.ts";

export default function getSearchItems(t: any): MaSearchItem[] {
  return [
    {
      label: "商品名称",
      prop: "commodity_name",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "商品名称" }) },
    },
    {
      label: "商品类型",
      prop: "commodity_category",
      render: () => MaRemoteSelect,
      renderProps: {
        api: commodityTypePage,
        dataHandle: (response: any) => {
          if (response.code === 200 && response.data && response.data.list) {
            return response.data.list.map((item: any) => ({
              label: item.name || `商品类型${item.id}`,
              value: item.id,
            }));
          }
          return [];
        },
        placeholder: "请选择商品类型",
        clearable: true,
        multiple: false,
      },
    },
    {
      label: "商品品牌",
      prop: "commodity_brand",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "商品品牌" }) },
    },
    {
      label: "商品型号",
      prop: "commodity_model",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "商品型号" }) },
    },
    {
      label: "销售价",
      prop: "sale_price",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "销售价" }) },
    },
    {
      label: "折扣",
      prop: "discount",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "折扣" }) },
    },
    {
      label: "满减金额",
      prop: "full_amount",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "满减金额" }) },
    },
    {
      label: "满减额度",
      prop: "full_reduction",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "满减额度" }) },
    },
    {
      label: "库存数量",
      prop: "stock_quantity",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "库存数量" }) },
    },
  ];
}
